<template>
	<view class="container">
		<view class="title">
			<text class="name">源聚变</text>
			<view class="search">
				<input class="search-input" placeholder-style="color:#fff" type="text" value="" placeholder="百事可乐" />
				<image class="search-img" src="../../static/index/search.png" mode=""></image>
			</view>
		</view>
		<view class="content" style="background-image: url('../../static/earn/earnBg.png');">
			<view class="sign-in">
				<view class="sign-in-top">
					<text>看视频赚积分</text>
					<text>一次可领20积分</text>
				</view>
				<view class="sign-in-bottom" style="white-space: nowrap;">
					<scroll-view class="scroll-view_H" scroll-x="true" @scroll="scroll" scroll-left="100">
						<view id="demo" class="scroll-view-item_H" v-for="(item,index) in signLists" :key='index'>
							<view class="aa">
								<image style="width: 60rpx;height: 60rpx;" :src="item.url" mode=""></image>
								<text
									style="font-size: 20rpx;font-family: Source Han Sans CN;font-weight: 400;color: #FF7200;">领积分</text>
							</view>
						</view>
					</scroll-view>
				</view>
			</view>
			<view class="new-task">
				<view class="new-task-title">
					<text>新手任务</text>
					<text>完成全部任务即可获得500积分</text>
				</view>
				<view class="new-task-content">
					<view class="new-task-circular">1</view>
					<view class="new-task-right">
						<view class="left-box">
							<view class="one">
								查看新手引导即可完成任务
							</view>
							<view class="two">
								完成之后即可获得100积分
							</view>
						</view>
						<view class="right-box" @click="noviceGuidance">
							去完成
						</view>
					</view>
				</view>
				<view class="new-task-content">
					<view class="new-task-circular">2</view>
					<view class="new-task-right">
						<view class="left-box">
							<view class="one">
								完成实名认证
							</view>
							<view class="two">
								完成之后即可获得100积分
							</view>
						</view>
						<view class="right-box">
							去完成
						</view>
					</view>
				</view>
				<view class="new-task-content">
					<view class="new-task-circular">3</view>
					<view class="new-task-right">
						<view class="left-box">
							<view class="one">
								观看2个视频即可完成任务
							</view>
							<view class="two">
								完成之后即可获得300积分
							</view>
						</view>
						<view class="right-box">
							去完成
						</view>
					</view>
				</view>
			</view>
			<view class="task">
				<view class="task-top">
					<image src="../../static/earn/left.png" mode=""></image>
					<text>做任务 赚积分</text>
					<image src="../../static/earn/right.png" mode=""></image>
				</view>
				<view class="task-bottom">
					<view class="task-bottom-box">
						<image src="../../static/earn/fenxiang.png" mode=""></image>
						<view class="task-bottom-box-miiddle">
							<text>邀请好友注册</text>
							<text>一个好友最高可得500积分</text>
						</view>
						<view class="btn">
							去邀请
						</view>
					</view>
					<view class="task-bottom-box">
						<image src="../../static/earn/guankan.png" mode=""></image>
						<view class="task-bottom-box-miiddle">
							<text>观看视频即可获得积分</text>
							<text>单次最高可获得40积分，单日最高可领取1000</text>
						</view>
						<view class="btn">
							去观看
						</view>
					</view>
					<view class="task-bottom-box">
						<image src="../../static/earn/wanshan.png" mode=""></image>
						<view class="task-bottom-box-miiddle">
							<text>完善信息</text>
							<text>完善信息可得50积分</text>
						</view>
						<view class="btn" @click="perfect">
							去完善
						</view>
					</view>
					<view class="task-bottom-box">
						<image src="../../static/earn/qiandao.png" mode=""></image>
						<view class="task-bottom-box-miiddle">
							<text>每日签到</text>
							<text>最高可领2000积分</text>
						</view>
						<view class="btn" @click="show=true">
							去签到
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 签到弹框 -->
		<u-popup :show="show" @close="close" :round="true" borderRadius="20" @open="open" mode="center" v-model='show' style="position: relative;">
			<view style="height: 896rpx;width: 748rpx;">
				<view class="top-pop">
					<view class="rili">
						<image @click="openRili" class="rili-img" src="../../static/earn/rili.png" mode=""></image>
						<text>签到日历</text>
					</view>
					<view class="top-pop-title">
						今日已签到成功！
					</view>
					<view class="date">
						已连续签到5天
					</view>
				</view>
				<view class="content-pop">
					<view class="content-pop-box" v-for="(item,index) in daysList" :key="index">
						<image v-if="item.isSign" src="../../static/earn/sign.png" style="width: 58rpx;height: 58rpx;" mode=""></image>
						<image v-else src="../../static/earn/nosign.png" style="width: 58rpx;height: 58rpx;" mode=""></image>
						<text class="days" :class="item.isSign?'active':''">第{{item.days}}天</text>
					</view>
				</view>
				<view style="font-size: 34rpx;font-weight: 400;color: #C7C7C7;display: flex;justify-content: center;align-items: center;">
					签到一次可得20积分
				</view>
				<view style="font-size: 34rpx;font-weight: 400;color: #C7C7C7;display: flex;justify-content: center;align-items: center;margin-top:20rpx">
                  连续签到14天可得<text style="color: #FF0000;">200</text>积分
				</view>
			</view>
			<image class="delete" src="../../static/earn/detele.png" @click="show=false" mode=""></image>
		</u-popup>
		<u-popup :show="showRili" :round="true" borderRadius="20" mode="center" v-model='showRili'>
			<view style="height: 896rpx;width: 748rpx;">
				 <my-sign-calendar
				   :signData="signData"
				   :signList="signList"
				   @callbackSign="callbackSign"
				 ></my-sign-calendar>
			</view>
		</u-popup>
		<tabbar></tabbar>
	</view>
</template>

<script>
	import {
		tabbar
	} from "../../components/tabbar/tabbar.vue"
	import mySignCalendar from '@/components/my-sign-calendar/my-sign-calendar'//日历弹框
	export default {
		components: {
			tabbar,
			mySignCalendar
		},
		data() {
			return {
				 signData: {
				   start: '2018-08-01', // 开始的日期（yyyy-mm-dd），默认‘2019-08-01’
				   ismake: true, // 是否开启补签
				   type: 'month' // 日历模式（月 => month，周 => week）
				 },
				 signList: [],//已签到日期数组
				show: false, //签到弹框
				showRili:false,//日历弹框
				daysList: [{
					days: '1',
					isSign: true
				}, {
					days: '2',
					isSign: false
				}, {
					days: '3',
					isSign: false
				}, {
					days: '4',
					isSign: false
				}, {
					days: '5',
					isSign: false
				}, {
					days: '6',
					isSign: false
				}, {
					days: '7',
					isSign: false
				},
				], //签到数组
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				signLists: [{
					url: require('../../static/earn/collarintegral.png')
				}, {
					url: require('../../static/earn/collarintegral.png')
				}, {
					url: require('../../static/earn/collarintegral.png')
				}, {
					url: require('../../static/earn/collarintegral.png')
				}, {
					url: require('../../static/earn/collarintegral.png')
				}, {
					url: require('../../static/earn/collarintegral.png')
				}, {
					url: require('../../static/earn/collarintegral.png')
				}, {
					url: require('../../static/earn/collarintegral.png')
				}, {
					url: require('../../static/earn/collarintegral.png')
				}, {
					url: require('../../static/earn/collarintegral.png')
				}]
			}
		},
		onLoad() {
		  // 获取签到数据
		  setTimeout(() => {
		    this.signList = [{ year: '2020', month: '3', day: '1'},
		      { year: '2020', month: '3', day: '10'}, 
		      { year: '2020', month: '4', day: '1'}, 
		      { year: '2020', month: '4', day: '3'}, 
		      { year: '2020', month: '4', day: '4'}, 
		      { year: '2020', month: '4', day: '5'},
		      { year: '2020', month: '12', day: '1'}
		    ]
		  }, 1000)
		},
		methods: {
			//新手引导
			noviceGuidance(){
				uni.navigateTo({
					url:'/myPackageA/mine/naviceTutorial'
				})
			},
			  // 签到回调
			  callbackSign(data) {
			    console.log(data,'签到回调数据')
			    // ajax请求，更新this.signList数据
			    // ajax请求成功，调用data.callback方法更新视图
			    data.callback && data.callback(data.data)
			    uni.showToast({
			      title: data.msg,
			      icon: 'none'
			    })
			  },
			//打开日历
			openRili(){
				this.show = false;
				this.showRili = true;
			},
			scroll(e) {
				console.log(e, 1111111111)
				this.old.scrollTop = e.detail.scrollTop
			},
			//去完善
			perfect() {
				uni.navigateTo({
					url: '/myPackageA/earn/perfectInfo'
				})
			},
			open() {
				// console.log('open');
			},
			close() {
				this.show = false
				// console.log('close');
			},
		}
	}
</script>

<style lang="less" scoped>
	.new-task{
		width: 90%;
		margin: 60rpx 5% 0;
		height: auto;
		padding-bottom: 30rpx;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 20rpx;
		padding: 30rpx;
		.new-task-content{
			display: flex;
			padding-bottom:40rpx ;
			.new-task-circular{
				width: 80rpx;
				height: 80rpx;
				background: linear-gradient(147deg, #FF7200 0%, #F3A96D 100%);
				border-radius: 50%;
				opacity: 1;
				font-size: 42rpx;
				font-weight: 400;
				color: #FFFFFF;
				line-height: 80rpx;
				text-align: center;
			}
			.new-task-right{
				flex: 1;
				margin-left: 20rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				.right-box{
					width: 118rpx;
					height: 44rpx;
					background: #FF7200;
					opacity: 1;
					border-radius: 22rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 28rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #FFFFFF;
				}
				.left-box{
					margin-right: 10rpx;
					flex: 1;
					.one{
						font-size: 32rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #333333;
					}
					.two{
						font-size: 28rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #FF0000;
					}
				}
			}
		}
		.new-task-title{
			padding: 14rpx 10rpx 14rpx;
			border-bottom: 2rpx solid #ECEAEA;
			margin-bottom: 40rpx;
			text:first-child{
				font-size: 36rpx;
				font-weight: 400;
				color: #FF7200;
			}
			text:last-child{
				font-size: 24rpx;
				font-weight: 400;
				color: #999999;
				margin-left: 20rpx;
			}
		}
	}
	.delete{
		width: 50rpx;
		height: 48rpx;
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		margin: 40rpx auto;
	}
	.content-pop {
		padding: 40rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.content-pop-box {
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			.days {
				font-size: 30rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				margin-top: 20rpx;
				color: #C7C7C7;
			}
			.active{
				color: #FF7200;
				font-size: 30rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				margin-top: 20rpx;
			}
		}
	}

	.top-pop {
		width: 100%;
		height: 412rpx;
		background-image: url('../../static/earn/signInBg.png');
		background-repeat: no-repeat;
		background-size: 100% 100%;
		background-position-y: -2px;
		background-position-x: 1px;
		.top-pop-title {
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 58rpx;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #FFFFFF;
			margin: 20rpx 0 32rpx;
		}

		.date {
			width: 304rpx;
			height: 58rpx;
			background: #FFFFFF;
			opacity: 1;
			line-height: 58rpx;
			text-align: center;
			border-radius: 40rpx;
			font-size: 38rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FF7200;
			display: flex;
			justify-content: center;
			align-items: center;
			margin: 10rpx auto;
		}

		.rili {
			padding: 40rpx;
			display: flex;
			justify-content: flex-end;

			.rili-img {
				width: 37rpx;
				height: 38rpx;
			}

			text {
				font-size: 30rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FFD298;
				margin-left: 5rpx;
			}

		}
	}

	.task-bottom {
		padding-bottom: 60rpx;
	}

	.task-bottom-box {
		margin-top: 30rpx;
		display: flex;
		align-items: center;
		height: auto;

		image {
			width: 88rpx;
			height: 88rpx;
		}

		.task-bottom-box-miiddle {
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: center;
			margin: 0 24rpx;

			text:first-child {
				font-size: 32rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
			}

			text:last-child {
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FF0000;
			}
		}

		.btn {
			width: 118rpx;
			height: 44rpx;
			background: #FF7200;
			border-radius: 20rpx;
			line-height: 44rpx;
			text-align: center;
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
		}
	}

	#demo {
		display: inline-block;
		width: 85rpx;
		padding-left: 44rpx;

		.aa {
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
		}
	}

	.content {
		width: 100%;
		height: auto;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		padding-top: 60rpx;
		padding-bottom: 60rpx;

		.task {
			width: 90%;
			margin: 60rpx 5% 0;
			height: 668rpx;
			background: #FFFFFF;
			opacity: 1;
			border-radius: 10rpx;
			padding: 0 36rpx;

			.task-top {
				height: 84rpx;
				width: 100%;
				border-bottom: 1px solid #ECEAEA;
				display: flex;
				align-items: center;
				justify-content: center;

				image {
					width: 42rpx;
					height: 22rpx;
					margin-top: 12rpx;
				}

				text {
					font-size: 36rpx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					color: #333333;
					margin: 0 14rpx;
				}
			}
		}

		.sign-in {
			width: 90%;
			margin: 514rpx 5% 0;
			height: 232rpx;
			background: #FFFFFF;
			opacity: 1;
			border-radius: 10rpx;

			.sign-in-top {
				display: flex;
				padding: 0rpx 46rpx;
				height: 90rpx;
				align-items: center;

				text:first-child {
					font-size: 36rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #333333;
				}

				text:last-child {
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #999999;
					margin-left: 16rpx;
				}
			}
		}
	}

	.title {
		display: flex;
		align-items: center;
		width: 100%;
		height: 176rpx;
		background: linear-gradient(153deg, #DD85FC 0%, #2172EB 100%);

		.name {
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			padding: 0 40rpx;
			margin-top: -2%;
		}

		.search {
			position: relative;
			margin-top: -2%;

			.search-input {
				background-color: rgba(225, 225, 225, 0.22);
				border-radius: 30rpx;
				padding-left: 60rpx;
				width: 302rpx;
				height: 64rpx;
				z-index: 99;
			}

			.search-img {
				width: 32rpx;
				height: 32rpx;
				position: absolute;
				top: 16rpx;
				left: 18rpx;
			}
		}
	}
</style>
